<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
class Cv_model extends CI_Model{
    public function __construct() {
        parent::__construct();
        $this->load->database();
    }
    public function getListCV()
    {
        $sql="select * from CV";
        $query=$this->db->query($sql);
        return $query;
    }
    public function getCVLimited($per_page,$start_row)
    {
        $query=$this->db->get('CV',$per_page,$start_row);
        return $query->result();
    }
    public function addCV($FullName,$FirstName,$LastName,$POB,$Marital,$Gender,$IDNumber,$DOI,$POI,$PersonalEmail1,$PersonalEmail2,$HomePhone,$CellPhone,$CVSumup,$DOB,$Foreigners,$PositionInterview)
    {
        $insertCV=array(
            'FullName'=>$FullName,
            'FirstName'=>$FirstName,
            'LastName'=>$LastName,
            'POB'=>$POB,
            'MaristalStatus'=>$Marital,
            'Gender'=>$Gender,
            'ID_Number'=>$IDNumber,
            'DOI'=>$DOI,
            'POI'=>$POI,
            'PersonalEmail1'=>$PersonalEmail1,
            'PersonalEmail2'=>$PersonalEmail2,
            'HomePhone'=>$HomePhone,
            'CellPhone'=>$CellPhone,
            'CV_Sumup'=>$CVSumup,
            'DOB'=>$DOB,
            'Foreigners'=>$Foreigners,
            'PositionInterview'=>$PositionInterview
        );
        $insert_CV=$this->db->insert('CV',$insertCV);
        return $insert_CV;
    }
    public function updateCV($CV_ID,$FullName,$FirstName,$LastName,$POB,$Marital,$Gender,$IDNumber,$DOI,$POI,$PersonalEmail1,$PersonalEmail2,$HomePhone,$CellPhone,$CVSumup,$DOB,$Foreigners,$PositionInterview)
    {
        $updateCV=array(
            'FullName'=>$FullName,
            'FirstName'=>$FirstName,
            'LastName'=>$LastName,
            'POB'=>$POB,
            'MaristalStatus'=>$Marital,
            'Gender'=>$Gender,
            'ID_Number'=>$IDNumber,
            'DOI'=>$DOI,
            'POI'=>$POI,
            'PersonalEmail1'=>$PersonalEmail1,
            'PersonalEmail2'=>$PersonalEmail2,
            'HomePhone'=>$HomePhone,
            'CellPhone'=>$CellPhone,
            'CV_Sumup'=>$CVSumup,
            'DOB'=>$DOB,
            'Foreigners'=>$Foreigners,
            'PositionInterview'=>$PositionInterview
        );
        $update_CV=$this->db->update('CV',$updateCV,array('CV_ID'=>$CV_ID));
        return $update_CV;
    }
    public function getFullNameByCVID($CV_ID)
    {
        $this->db->where('CV_ID',$CV_ID);
        $query=$this->db->get('CV');
        return $query;
    }
    public function getListExperienceCV($CV_ID)
    {
        $this->db->where('CV_ID',$CV_ID);
        $query=$this->db->get('Experience');
        return $query;
    }
    public function checkExperienceCV($CV_ID,$Education,$PreviousPosition,$Company,$Industry,$Year)
    {
        $this->db->where('CV_ID',$CV_ID);
        $this->db->where('Education',$Education);
        $this->db->where('PreviousPosition',$PreviousPosition);
        $this->db->where('Company',$Company);
        $this->db->where('Industry',$Industry);
        $this->db->where('Year',$Year);
        $query=$this->db->get('Experience');
        return $query;
        
    }
    public function insertExperienceCV($CV_ID,$Education,$PreviousPosition,$Company,$Industry,$Year)
    {
        $insert_experience_cv=array(
            'CV_ID'=>$CV_ID,
            'Education'=>$Education,
            'PreviousPosition'=>$PreviousPosition,
            'Company'=>$Company,
            'Industry'=>$Industry,
            'Year'=>$Year
        );
        $insertexperiencecv=$this->db->insert('Experience',$insert_experience_cv);
        return $insertexperiencecv;
    }
    public function checkIDNumberExist($ID_Number)
    {
        $this->db->where('ID_Number',$ID_Number);
        $query=$this->db->get('CV');
        return $query;
    }
    public function getCVByCVID($CV_ID)
    {
        $this->db->where('CV_ID',$CV_ID);
        $query=$this->db->get('CV');
        return $query;
    }
}
?>
